package leetcode.hot100;

public class Solution55 {

    public static void main(String[] args) {
        int[] nums = {2,0,0};
        System.out.println(new Solution55().canJump(nums));
    }

    public boolean canJump(int[] nums) {
        return backTrack(nums,nums.length-1,0);
    }

    public boolean backTrack(int[] nums, int target, int startIdx){
        if(target<=0) return true; //已经到达
        for (int i = nums[startIdx]; i > 0 ; i--) {
            if(backTrack(nums,target-i,startIdx+i)){
                return true;
            }
        }
        return false;
    }
}
